package com.example.xueshen.common.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.example.xueshen.common.dao.TeacherDao;


import com.example.xueshen.common.entity.Teacher;
import com.example.xueshen.common.service.TeacherService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;
@Service
public class TeacherServiceImpl implements TeacherService {
    @Resource
    private TeacherDao teacherDao;
    @Override
    public List<Teacher> getAll() {
        return teacherDao.selectList(null);
    }

    @Override
    public boolean toAdd(Teacher teacher) {
        return teacherDao.insert(teacher)>0;
    }

    @Override
    public boolean update(Teacher teacher) {
        return teacherDao.updateById(teacher)>0;
    }

    @Override
    public Teacher getById(Integer tid) {
        return teacherDao.selectById(tid);
    }

    @Override
    public boolean deleteById(Integer tid) {
        return teacherDao.deleteById(tid)>0;
    }

    @Override
    public Page<Teacher> selectBy(Page<Teacher> page, QueryWrapper<Teacher> queryWrapper) {
        return teacherDao.selectPage(page,queryWrapper);
    }
}
